package com.voxel.sense.infomsg.module.user.personal.details;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.com.common.app.BaseActivity;
import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.module.user.personal.edit.EditBaseInfoActivity;
import com.voxel.sense.infomsg.module.user.personal.portrait.SetMyPortraitActivity;
import com.voxel.sense.infomsg.utils.GlideUtils;
import com.voxel.sense.infomsg.view.titlebar.TextTitleBar;

import butterknife.BindView;
import butterknife.OnClick;
import cyy.example.com.facotry.Factory;
import cyy.example.com.facotry.constants.Constants;
import cyy.example.com.facotry.share.SPEngine;

public class UserDetailsActivity extends BaseActivity {
    @BindView(R.id.iv_portrait)
    ImageView iv_portrait;
    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_phone)
    TextView tv_phone;
    @BindView(R.id.tv_email)
    TextView tv_email;
    @BindView(R.id.titlebar)
    TextTitleBar titlebar;


    public static void show(Context context) {
        context.startActivity(new Intent(context, UserDetailsActivity.class));
    }

    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_user_details;
    }

    @Override
    protected void initData() {
        super.initData();
    }

    @Override
    protected void onResume() {
        super.onResume();
        SPEngine.UserInfo userInfo = SPEngine.getSPEngine().getUserInfo();
        String phone = userInfo.getPhone();
        String name = userInfo.getName();
        String email = userInfo.getEmail();
        String portrait = userInfo.getPortrait();

        tv_email.setText(email);
        tv_name.setText(name);
        tv_phone.setText(phone);
        GlideUtils.GlideLoadPortrait(Factory.app(), portrait, iv_portrait);
    }

    @Override
    protected void initWidget() {
        super.initWidget();
        titlebar.setTitleText(R.string.personal_info);

    }

    @OnClick({R.id.tv_phone, R.id.tv_email, R.id.tv_name, R.id.tv_portrait})
    void onClickEvent(View view) {
        if (view.getId() == R.id.tv_phone) {
            EditBaseInfoActivity.show(this, Constants.EDIT_Phone);
        } else if (view.getId() == R.id.tv_email) {
            EditBaseInfoActivity.show(this, Constants.EDIT_Email);
        } else if (view.getId() == R.id.tv_name) {
            EditBaseInfoActivity.show(this, Constants.EDIT_NAME);
        } else if (view.getId() == R.id.tv_portrait) {
            //不让修改头像
//            SetMyPortraitActivity.show(this);
        }
    }
}
